package com.vol;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

@Component
public class RedisUtils<E> {


    @Resource
    private RedisTemplate<String, E> redisTemplate;

    public void setKey(String key, E value) {
        redisTemplate.opsForValue().set(key, value);
    }

    public E getKey(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    public void clear(){
        redisTemplate.getConnectionFactory().getConnection().flushDb();
    }



}
